#include <log4cpp/Category.hh>
#include <log4cpp/FileAppender.hh>
#include <log4cpp/PatternLayout.hh>
#include <log4cpp/Priority.hh>

int main() {
    // Create an appender
    log4cpp::Appender *appender = new log4cpp::FileAppender("default", "../demo.log");

    // Set a layout
    appender->setLayout(new log4cpp::BasicLayout());

    // Create a category and set priority
    log4cpp::Category &root = log4cpp::Category::getRoot();
    log4cpp::Category &category = root.getInstance("example");
    category.setPriority(log4cpp::Priority::DEBUG);
    category.addAppender(appender);

    // Log some messages
    category.info("This is an informational message.");
    category.warn("This is a warning message.");
    category.error("This is an error message.");
    category.debug("This is a debug message.");

    // Shutdown log4cpp
    log4cpp::Category::shutdown();

    return 0;
}
